import matplotlib
matplotlib.use('MacOSX')
import matplotlib.pyplot as plt


def drawTraj(data):
    """
    绘制车辆轨迹
    """
    x = data['x']
    y = data['y']
    plt.plot(x, y, 'r')
    plt.show()


def drawY(data):
    """
    绘制车辆轨迹
    """
    y = data['y']
    plt.plot(y, 'r')
    plt.show()


def drawY_diff(data1, data2):
    """
    绘制车辆轨迹
    """
    if type(data1) != list:
        data1 = data1['y']
    if type(data2) != list:
        data2 = data2['y']

    plt.plot(data1, 'r')
    plt.plot(data2, 'b')
    plt.show()

def draw_diff(data1, data2):
    """
    绘制车辆轨迹
    """
    x1 = data1['x']
    y1 = data1['y']
    x2 = data2[0]
    y2 = data2[1]
    plt.plot(x1, y1, 'r')
    plt.plot(x2, y2, 'b')
    plt.axis('equal')
    plt.savefig('result.png')
    plt.show()
